package com.huashi.dealer.commonEntity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;

import java.time.LocalDateTime;

/**
 * 小程序prepay_id实体类
 */
@Getter
@Setter
@TableName("yoshop_wxapp_prepay_id")
@Schema(description = "小程序prepay_id实体")
public class WxappPrepayId {

    @TableId(value = "id", type = IdType.AUTO)
    @Schema(description = "ID")
    private Long id;

    @TableField("order_id")
    @Schema(description = "订单ID")
    private Long orderId;

    @TableField("order_type")
    @Schema(description = "订单类型：10主订单，20子订单")
    private Integer orderType;

    @TableField("prepay_id")
    @Schema(description = "预支付ID")
    private String prepayId;

    @TableField("used_times")
    @Schema(description = "已使用次数")
    private Integer usedTimes;

    @TableField("can_use_times")
    @Schema(description = "可用次数")
    private Integer canUseTimes;

    @TableField("pay_status")
    @Schema(description = "支付状态：0未支付，1已支付")
    private Integer payStatus;

    @TableField("is_delete")
    @TableLogic
    @Schema(description = "软删除标记")
    private Integer isDelete;

    @TableField("create_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Schema(description = "创建时间")
    private LocalDateTime createTime;

    @TableField("update_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Schema(description = "更新时间")
    private LocalDateTime updateTime;

    /**
     * 获取订单类型文本
     */
    @JsonProperty("orderTypeText")
    public String getOrderTypeText() {
        switch (orderType) {
            case 10: return "主订单";
            case 20: return "子订单";
            default: return "";
        }
    }

    /**
     * 获取支付状态文本
     */
    @JsonProperty("payStatusText")
    public String getPayStatusText() {
        switch (payStatus) {
            case 0: return "未支付";
            case 1: return "已支付";
            default: return "";
        }
    }
} 